﻿<table cellspacing="0px" style="margin:0;">
    <tr>
        <td width="70px">
            <input id="FMiniShopID" name="FMiniShopID" class="mini-buttonedit" style="width:70px;" 
                onbuttonclick="getMiniShopID('')" onvaluechanged ="getMiniShopValueChanged" selectOnFocus="true" />
        </td>
        <td width="126px">
            <input id="FMiniShopName" name="FMiniShopName" class="mini-textbox" style="width:126px;"
                enabled = "false"  align="left" readonly="readonly"/>
        </td>
    </tr>
</table>

<script>
    ///增加用户组,打开GetItemID.js的
    function getMiniShopID(mSearchKey) {
        mini.open({
            url: "../GetItem/Index",
            title: "小程序App设置选择", width: 730, height: 460,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "new", sTbName: "XcxApp", sSearchKey: mSearchKey};
                iframe.contentWindow.SetData(data);//打开GetItemID.js的SetData
            },
            ondestroy: function (action) {
                if (action.length > 0) {
                    mini.get("FMiniShopID").setValue(action[0].FItemID);
                    mini.get("FMiniShopID").setText(action[0].FNumber);
                    mini.get("FMiniShopName").setValue(action[0].FName);
                }
                else {
                    mini.get("FMiniShopID").setValue('');
                    mini.get("FMiniShopID").setText('');
                    mini.get("FMiniShopName").setValue('');
                }
            }
        });
    }

    function getMiniShopValueChanged() {
        var sSearchKey = mini.get("FMiniShopID").getText();
        var mAppID = parent.window.getSystemAppID();
        if (sSearchKey == "") {
            mini.get("FMiniShopName").setValue("");
            return;
        }
        var sTbName = "XcxApp";
        var json = "[{";
        json = json + "'FSystemAppID':" + "'" + mAppID + "',";
        json = json + "'FTbName':" + "'" + sTbName + "',";
        json = json + "'FNumber':" + "'" + sSearchKey + "'";
        json = json + "}]";
        $.post("../GetItem/GetItemList", { datajson: json }, function (text) {
            var sdata = mini.decode(text);
            if (sdata.data.length == 1) {
                mini.get("FMiniShopID").setValue(sdata.data[0].FItemID);
                mini.get("FMiniShopID").setText(sdata.data[0].FNumber);
                mini.get("FMiniShopName").setValue(sdata.data[0].FName);
            }
            else {
                mini.get("FMiniShopID").setValue("");
                mini.get("FMiniShopID").setText("");
                mini.get("FMiniShopName").setValue("");
            }
        });
    }
</script>